package com.ptp.manage;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.ptp.chat.MessageInfo;
import com.ptp.message.Message;

import io.netty.channel.Channel;
import io.netty.util.internal.StringUtil;

/** 
 * @author liningning 
 * @date 2018年12月4日 下午3:04:30 
*/
public class ChannelManage {

	public static Map<String, Channel> channels = new ConcurrentHashMap<>();
	
	public static Map<String, MessageInfo> received = new ConcurrentHashMap<>();
	
	public static Map<String, Message> messages = new ConcurrentHashMap<>();
	
	public static boolean isReceived(String userId,String ipAddr,String messageId) {
		if(!StringUtil.isNullOrEmpty(userId)) {
			MessageInfo msgInfo = received.get(userId+messageId);
			if(msgInfo != null) {
				return false;
			}
		}else if(!StringUtil.isNullOrEmpty(ipAddr)){
			MessageInfo msgInfo = received.get(ipAddr+messageId);
			if(msgInfo != null) {
				return false;
			}
		}
		
		return true;
	}
}
